﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AD.Model;
using AD.BLL;

/// <summary>
///AliPayPageBase 的摘要说明
/// </summary>
public class AliPayPageBase : System.Web.UI.Page
{
    protected void CheckTrade(string order_no)
    {
        PayTradeMod pay = PayTradeBLL.QueryByTradeNo(order_no);
        if (pay != null && pay.Status != true)
        {
            if (PayTradeBLL.UpdateInMoneyStatus(order_no) > 0)
            {
                pay = PayTradeBLL.QueryByTradeNo(order_no);
                if (pay != null && pay.IsInMoney && pay.Status == false)
                {
                    UserMod user = UserBLL.QueryById(pay.UserId);
                    if (user != null && PayTradeBLL.UpdatePaySuccessStatus(order_no, true) > 0)
                    {
                        pay = PayTradeBLL.QueryByTradeNo(order_no);
                        if (pay != null && pay.IsInMoney && pay.Status)
                        {
                            if (UtilHepler.UpdateAccountFlow(user, "alipay", pay.RewardPoints,OperationType.InMoney) > 0)
                                PayTradeBLL.UpdatePaySuccessStatus(order_no, false);
                        }
                    }
                }
            }
        }
    }
}